/**
 * Project Name:kany-project-blog-web
 * File Name:FileNotFoundExceptionMapper.java
 * Package Name:me.kany.project.blog.resource.mapper
 * Date:2016年9月22日上午1:49:11
 * Copyright (c) 2016, Jason.Wang All Rights Reserved.
 *
*/

package me.kany.project.blog.resource.mapper;

import java.io.FileNotFoundException;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;

import me.kany.project.blog.resource.model.GenericErrorMessage;

/**
 * ClassName:FileNotFoundExceptionMapper <br/>
 * Function: 自定义文件异常. <br/>
 * Date:     2016年9月22日 上午1:49:11 <br/>
 * @author   Jason.Wang
 * @version  
 * @since    JDK 1.7
 * @see 	 
 */
public class FileNotFoundExceptionMapper implements ExceptionMapper<FileNotFoundException> {

	@Override
	public Response toResponse(FileNotFoundException exception) {
		GenericErrorMessage e = new GenericErrorMessage();
		e.setMessage(exception.getMessage());
		e.setCode(Status.UNAUTHORIZED.getStatusCode());

		return Response.status(Status.UNAUTHORIZED).type("application/json").entity(e).build();
	}

}
